<%@page import="com.office.automate.service.impl.employee.EmployeeServiceImplementer"%>
<%@page import="com.office.automate.service.def.employee.EmployeeService"%>
<%@page import="com.office.automate.model.employee.EmployeeAttendance"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="com.office.automate.frontier.utility.DataConversionUtility"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="../common/CommonHeaderInfo.jsp"%>
<title>Update Employee</title>
</head>
<body>
	<%@ include file="../common/SiteHeaderSection.jsp" %>
	<%@ include file="../common/LeaveManagementMenu.jsp"%>

		<%
			if (currentUser == null) {
				return;
			}
			Properties configSeqPropspg = ConfigurationProperties.getProps(); 
			Utility utilpg = new Utility(currentUser.getSecurityLevels());
			if (!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("MAIN_LEAVE_MANAGEMENT")) ||  
						!utilpg.isFunctionalSecurityAllow(configSeqPropspg.getProperty("DAILY_ATTENDANCE")))  {
				response.sendRedirect("/OfficeAutomation/jsp/HomePage.jsp");
			}
			DataConversionUtility dcu = new DataConversionUtility();
			Calendar tdt = Calendar.getInstance();
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			EmployeeService employeeService = new EmployeeServiceImplementer();
			EmployeeAttendance employeeAttendance = employeeService.getEmployeeAttendanceDetailsForCurrentWeek(currentUser.getEmployeeId());
		%>
	<tr>
		<td colspan="3"><center><font class="formtablecaption"><u>Employee Attendance Check-In/Out</u></font></center><br /></td>
	</tr>
	<tr>
		<td>
		  <center>
			<table class="datagridstyle">
				<tr class="grid-heding-row-style">
					<th class="grid-heding-cell-style">  </td>
					<th class="grid-heding-cell-style"> Sunday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 1)) %></th>
					<th class="grid-heding-cell-style"> Monday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 2)) %></th>
					<th class="grid-heding-cell-style"> Tuesday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 3)) %></th>
					<th class="grid-heding-cell-style"> Wednesday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 4)) %></th>
					<th class="grid-heding-cell-style"> Thursday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 5)) %></th>
					<th class="grid-heding-cell-style"> Friday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 6)) %></th>
					<th class="grid-heding-cell-style"> Saturday <%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 7)) %></th>
				</tr>
				<tr class="data-row-even-style">
					<td class="data-row-cell-style"> Sign In </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Sunday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 1)) %>"> <input type="submit" value="Sign In"
					 <% if (employeeAttendance.isSundayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 1)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Monday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 2)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isMondayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 2)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Tuesday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 3)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isTuesdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 3)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Wednesday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 4)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isWednesdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 4)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Thursday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 5)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isThursdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 5)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Friday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 6)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isFridayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 6)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Saturday-In"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 7)) %>"><input type="submit" value="Sign In" 
					<% if (employeeAttendance.isSaturdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 7)))) { %>disabled="disabled" <% } %>/></form> </td>
				</tr>
				<tr class="data-row-odd-style">
					<td class="data-row-cell-style"> Sign Off </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Sunday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 1)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isSundayOut() || !employeeAttendance.isSundayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 1)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Monday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 2)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isMondayOut() || !employeeAttendance.isMondayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 2)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Tuesday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 3)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isTuesdayOut() || !employeeAttendance.isTuesdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 3)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Wednesday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 4)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isWednesdayOut() || !employeeAttendance.isWednesdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 4)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Thursday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 5)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isThursdayOut() || !employeeAttendance.isThursdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 5)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Friday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 6)) %>"><input type="submit" value="Sign Out" 
					<% if (employeeAttendance.isFridayOut() || !employeeAttendance.isFridayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 6)))) { %>disabled="disabled" <% } %>/></form> </td>
					<td class="data-row-cell-style"> <form action="/OfficeAutomation/EmployeeAttendanceServlet" method="post"> <input type="hidden" name="level" value="Saturday-Out"> <input type="hidden" name="attdate" value="<%=formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 7)) %>"><input type="submit" value="Sign Out"
					<% if (employeeAttendance.isSaturdayOut() || !employeeAttendance.isSaturdayIn() || !dcu.validateTodayDate(formatter.format(dcu.getDatesOfGivenWeek(tdt.getTime(), 7)))) { %>disabled="disabled" <% } %>/></form> </td>
				</tr>
				<tr class="data-row-even-style">
					<td class="data-row-cell-style"> Time Entry(H) </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getSundayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getMondayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getTuesdayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getWednesdayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getThursdayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getFridayWorkingHours()) %> </td>
					<td class="data-row-cell-style"> <%= String.format("%.2f", employeeAttendance.getSaturdayWorkingHours()) %> </td>
				</tr>
			</table>
		  </center>
	  	</td>
	</tr>
<%@ include file="../common/SiteFotterSection.jsp" %>
</body>
</html>